//turn the list with single list
#include <iostream>
#include <stdlib.h>

using namespace std;

struct List
{
    int data;
    List* next;
};

List* Creat_list(int n)
{
    List* head;
    head=(List*) malloc(sizeof(List));
    if(head==NULL) cout<<"error,fail to creat the list"<<endl;
    else
    { 
        List* p=head;
        for(int i=0;i<n;i++)
        {
            cout<<"enter the value"<<endl;
            cin>>p->data;
            List* p1=(List*) malloc(sizeof(List));
            if(p1==NULL) cout<<"error,fail to creat the list"<<endl;
            else
            {
                p->next=p1;
                p=p1;
            }            
        }
        p->next=NULL;
    }
    return head;
}

List* turn_list(List* head)
{
    List* thead1=(List* )malloc(sizeof(List));
    thead1->next=NULL;
    while(head!=NULL)
    {
        
        thead1->data=head->data;
        head=head->next;
        List* thead=(List* )malloc(sizeof(List));
        thead->next=thead1;
        thead1=thead;
    }
    return thead1->next;
}
void display_list(List*head)
{
    while(head->next!=NULL)
    {
        cout<<head->data<<"  ";
        head=head->next;
    }
}

int main ()
{
    List* head;
    int n;
    cout<<"enter the size of list"<<endl;
    cin>>n;
    head=Creat_list(n);
    head=turn_list(head);
    display_list(head);

    system("pause");
    return 0;
}
